﻿Imports System.IO
Public Class LayHinh
    Dim _img As Image
    Dim path As String = Directory.GetCurrentDirectory
    Sub New()
        _img = New Bitmap(10, 10)
    End Sub
    Public Property IMG As Image
        Get
            Return _img
        End Get
        Set(value As Image)
            _img = value
        End Set
    End Property
    Function ResizImg(ByVal img As String, width As Integer, height As Integer)
        Dim bm As New Bitmap(width, height)
        If File.Exists(img) = False Then
            Dim gr = Graphics.FromImage(bm)
            gr.DrawImage(Image.FromFile(path + "\" + "not_found.gif"), 0, 0, width, height)
            Return bm
        Else
            Dim gr = Graphics.FromImage(bm)
            gr.DrawImage(Image.FromFile(img), 0, 0, width, height)
            Return bm
        End If

    End Function
    Function ReDraw(ByVal img As Image, width As Integer, height As Integer)
        Dim bm As New Bitmap(width, height)
        Dim gr = Graphics.FromImage(bm)
        gr.DrawImage(img, 0, 0, width, height)
        Return bm
    End Function
    Function LuuHinh(ByVal f As String, ByVal _path As String) As String
        Dim newname As String = DateTime.Now.ToString("yyyyMMddHHmmss") + IO.Path.GetExtension(f).ToString
        Dim fol As String
        fol = path & "\images\" + _path + newname
        File.Copy(f, fol)
        Return newname
    End Function
End Class
